package com.bvgol.examples.springboot.mybatismultiple.controller;

import com.alibaba.fastjson.JSON;
import com.bvgol.examples.springboot.mybatismultiple.entity.Book;
import com.bvgol.examples.springboot.mybatismultiple.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mybatisMutilple/book")
public class BookController {

    @Autowired
    private BookService bookService;

    @GetMapping(value = "/books")
    public Object selectAll() {
        List<Book> books = bookService.selectAll();
        return JSON.toJSONString(books);
    }
}
